﻿using System.Linq;
using System.Windows.Shapes;

namespace DynamicGeometry
{
    public class DilatedPoint : PointBase, IPoint
    {
        double factor;

        public double Factor
        {
            get { return factor; }
            set { factor = value; }
        }

        protected override Shape CreateShape()
        {
            return Factory.CreateDependentPointShape();
        }

        public override void Recalculate()
        {
            var source = Point(0);
            var center = this.Dependencies.ElementAt(1);
            IPoint centerPoint = center as IPoint;
            if (centerPoint != null)
            {
                Coordinates = Math.GetDilationPoint(source, centerPoint.Coordinates,factor);
            }
            Exists = Coordinates.Exists();
        }
    }
}